<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>

<title>Admin Login</title>
<!-- Bootstrap -->
<!-- /container -->
<head>
<!-- HTML5 shim, for IE6-8 support of HTML5 elements -->
<!--[if lt IE 9]>
      <script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
    <![endif]-->
<%@include file="../common/header.jsp"%>
<!-- Bootstrap -->
<!-- HTML5 shim, for IE6-8 support of HTML5 elements -->
<!--[if lt IE 9]>
      <script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
    <![endif]-->

</head>

<body id="login">
	<div class="container" >

		<form class="form-signin" id="form">
			<h2 class="form-signin-heading">请登录</h2>
			<div class="form-group">
				<input type="text" class="input-block-level" placeholder="请输入帐号"
					name="username" required>
				<div class="help-block with-errors"></div>
			</div>
			<div class="form-group">
				<input type="password" class="input-block-level" placeholder="请输入密码"
					name="password" required>
				<div class="help-block with-errors"></div>
			</div>

			<button class="btn btn-large btn-primary" type="submit">登录</button>
		</form>
		<center>没有帐号？开始<a>注册</a></center>
	</div>

<%@include file="../common/foot.jsp"%>
</body>

<script>
	// 表单验证初始化
	$('#form').validator();
	$('#form').validator().on('submit', function(e) {
		if (e.isDefaultPrevented()) {
			// handle the invalid form...
		} else {
			
			$.ajax({
				url : "${pageContext.request.contextPath}/login/action?" + $("#form").serialize(),
				dataType : "json",
				type : "post",
				success : function(data) {
					debugger;
					if (data.header.status==100) {
						showSuccessAlert(data.header.msg);
						window.location.href="${pageContext.request.contextPath}/login/view/index";
					} else {
						showWarningAlert(data.header.msg);
					}
				},
				error : function() {
					showErrorAlert(data.header.msg);
				}
			});
			return false;
		}
	});
</script>

</html>